﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EmpresasDeOmnibus.Models;
using WebMatrix.WebData;

namespace EmpresasDeOmnibus.Controllers
{
    public class AccountController : Controller
    {
        public ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Login(LoginAccount datosLogin)
        {
            if (WebSecurity.Login(datosLogin.NombreUsuario, datosLogin.Clave, false))
            {
                return RedirectToAction("Index", "Home");
                //return RedirectToRoute(Request.UrlReferrer);
            }
            return View(model: datosLogin);
        }

        public ActionResult Logout()
        {
            WebSecurity.Logout();
            return RedirectToAction("Login");
        }
    }
}